package com.forum.mapper.talk;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.forum.pojo.talk.TalkPostsComment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author Tsing
 * 聊吧论坛评论Mapper
 */
@Mapper
@Repository
public interface TalkPostsCommentMapper extends BaseMapper<TalkPostsComment> {

    /**
     * 获取评论列表
     * @return List<></>
     * @param postId 帖子ID
     * @param page 当前页
     * **/
    @Select("select id, posts_id, publisher_id, content, create_time from talk_posts_comment where posts_id =${postId} limit ${page},10;")
    List<TalkPostsComment> getCommentList(@Param("postId") Integer postId,@Param("page") Long page);

    /**
     * 统计上述SQL的总量
     * @return Long
     * @param postId 帖子ID
     * **/
    @Select("select count(id) from talk_posts_comment where posts_id =${postId}")
    Long commentCount(@Param("postId") Integer postId);


}
